package 状态模式;

/**
 * @author zzs
 * @ClassName Sweet.java
 * @Description
 * @createTime 2022年05月18日 20:43:00
 */
public class Sweet {
    /**
     * 当前状态
     */
    public static Status status;

    public static Integer quantity = 0;

    private HaveQuantity haveQuantity;

    private NoQuantity noQuantity;

    private SoldOut soldOut;

    public Sweet() {
        haveQuantity = new HaveQuantity(this);
        noQuantity = new NoQuantity(this);
        soldOut = new SoldOut(this);
        status = noQuantity;
    }

    public HaveQuantity getHaveQuantity() {
        return haveQuantity;
    }

    public NoQuantity getNoQuantity() {
        return noQuantity;
    }

    public SoldOut getSoldOut() {
        return soldOut;
    }


    public void put() {
        quantity += 25;
        status.put();
    }

    public void turn() {
        quantity -= 25;
        status.turn();
    }

    public void refund() {
        if (quantity > 0) {
            status.refund();
        }
    }

    public void pop() {
        status.pop();
    }
}
